package edu.xpu.compute.recommend.dataGenerator;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import edu.xpu.compute.recommend.entity.SysUser;
import edu.xpu.compute.recommend.service.SysUserService;

@Component
public class SysUserDataGenerator {

	public static String[] FIRST_NAME_ARR = new String[]{
		"赵", "田", "孙", "李", "周", "吴", "郑", "王", "陈", "刘",
		"许", "徐", "姚", "高", "胡", "柳", "魏", "石", "张", "李",
		"董", "薛", "曹", "鲁", "高", "程", "宋", "杨", "郭", "冯",
		"任"
	};
	public static String[] LAST_NAME_ARR = new String[]{
		"娟", "康", "凯泽", "凯", "宇", "宇飞", "田", "建国", "倩", "甜甜", "攀", "建峰", "文龙", "龙",
		"峰", "志刚", "菲", "亚山", "亚茹", "露", "涛", "强", "晓", "妮", "勇", "超", "学军", "智", "瑞刚",
		"茸", "一博", "博", "晨", "晨涛", "欣", "帅", "娇", "凯莉", "浩", "豪杰", "子涵", "子轩", "子怡",
		"靖苗", "苗", "凯", "媛媛", "喜峰", "斌", "佑彬", "立杰", "茜铭", "明荣", "孙涛", "波涛", "红", "翔",
		"盈", "英", "磊", "增辉", "律", "超", "永涛", "小川", "白", "商银", "正", "三桂"
	};
	@Autowired
	private SysUserService sysUserService;
	
	/**
	 * 生成用户数据
	 */
	public void userGenerator() {
		Random random = new Random();
		int firstLen = FIRST_NAME_ARR.length;
		int lastLen = LAST_NAME_ARR.length;
		Date currentDate = new Date();
		DecimalFormat df = new DecimalFormat("0000");
		for (int i = 0; i < 1000; i++) {
			SysUser sysUser = new SysUser();
			sysUser.setSex(random.nextInt(2));
			sysUser.setPwd("111111");
			sysUser.setStudentNumber("NO.121"+df.format(i));
			String name = FIRST_NAME_ARR[random.nextInt(firstLen)] + LAST_NAME_ARR[random.nextInt(lastLen)];
			sysUser.setName(name);
			sysUser.setCreateDate(currentDate);
			sysUserService.save(sysUser);
		}
		
	}
}
